addEvent(window, "load", function() { show_player_info(document.existing.player_id); });

function loadXMLDoc(url, div) 
{
	var req;
	// branch for native XMLHttpRequest object
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChange(req, div, false);
		req.open("GET", url, true);
		req.send(null);
		// branch for IE/Windows ActiveX version
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.onreadystatechange = processReqChange(req, div, false);
			req.open("GET", url, true);
			req.send();
		}
	}
}

function processReqChange(req, div, process) 
{
	if (!process) 
		return function() { processReqChange(req, div, true); };


	if (req.readyState == 1)
	{
		div.innerHTML = "Wait...";
	}

	// only if req shows "complete"
	if (req.readyState == 4) {
		// only if "OK"
		if (req.status == 200) {
			// ...processing statements go here...
			/*
			response  = req.responseXML.documentElement;
			method    =
				response.getElementsByTagName('method')[0].firstChild.data;
			result    = 
				response.getElementsByTagName('result')[0].firstChild.data;
			eval(method + '(\'\', result)');
			*/
			div.innerHTML = req.responseText;
		} else {
			alert("There was a problem retrieving the XML data:\n" + req.statusText);
		}
	}
}

function show_player_info(select, div)
{
	player_id = select.options[select.selectedIndex].value; 

	loadXMLDoc("player_info.php?player="+player_id, div);
}
